﻿using BuyingSpree_HPV.Help;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace BuyingSpree_HPV
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {

            DispatcherUnhandledException += (sender, args) =>
            {
                LoggerHelper.log.Info(args.Exception.Message);
            };
            //Task线程未捕获异常处理事件
            TaskScheduler.UnobservedTaskException += (sender, args) =>
            {
                LoggerHelper.log.Info(args.Exception.Message);
            };
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                if (args.IsTerminating)
                {
                    GC.Collect();
                    LoggerHelper.log.Info(sender.ToString());
                    HandyControl.Controls.MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,公共语言运行时已经终止,请重新启动程序,如果还遇到此情况,请联系我们。 ", "应用程序即将终止",
                        MessageBoxButton.OK, MessageBoxImage.Error);
                }
            };
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            log4net.Config.XmlConfigurator.Configure();
            base.OnStartup(e);
            LoggerHelper.log.Info("==Startup=====================>>>");
        }
    }
}
